<% content_for :body_content_title do %>
  <%= @product.name %>
<% end %>

<% content_for :body_content_left do %>
    <div class="pod threequarter product_wider alpha">
		<div class="corner"><img src="/images/corner.png" /></div>
		<div class="image"><%= image_fu(@product.image, "400x400#c", :id => "variant_id") %></div>
		<hr>
		<div class="productname"><%= raw @product.name %></div>	
		<p><i><%= raw @product.summary %></i></p>
		<div class="price">Price: <%= raw rands(@product.price) %></div>
		<div class="add_to_cart">
      <% if RefinerySetting.find_or_set(:use_product_inquiry, false) %>
        <p><%= link_to("Find Out More", product_inquiry_path(:product_id => @product.id)) %></p>
      <% else %>
        <%= form_tag(add_to_cart_path(@product)) do |f| %>
          <% if defined?(Variant) && @product.variants.present? %>
            <%= collection_select(:variant, :id, @product.variants.order(:name), :id, :name, {}, {:class => "variant"})  -%>
          <% end %>
          <p><%= image_submit_tag("/images/cart.png") %></p>
        <% end %>
      <% end %>
		</div>
	</div>

	<% if @tagged_products.present? and @tagged_products.first.id != @product.id %>
		<h2>Customers who bought this also bought...</h2>
		<% @tagged_products.each do |product| %>
			<% unless product.id == @product.id %>
				<div class="pod quarter product omega">
					<div class="corner"><img src="/images/corner.png" /></div>
					<%= link_to(image_fu(product.image, "200x200#c", :id => "variant_id"), product_path(product)) %>
					<hr>
					<div class="productname"><%= raw product.name %></div>	
					<p><i><%= raw product.description %></i></p>
					<div class="add_to_cart">
							<p><%= link_to "Details", product_path(product) %></p>						
					</div>
				</div>
			<% end %>
	    <% end %>
	<% end %>
<% end %>


<%= render :partial => "/shared/content_page" %>

<script type="text/javascript">
$(document).ready(function() { 
	$('.variant').change(function() {  
		change_variant();
	});

	change_variant();

	function change_variant() {  
		var currentId = $('.variant').val();
    	
		$.get('/get_variant_image/'+currentId, function(data) {
		  $('img#variant_id').attr('src', data);
		});

		$.get('/get_variant_price/'+currentId, function(data) {
		  $('.price').html('Price: '+data);
		});
	}	
}); 
</script>
